home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / editors / emacs / xemacs / xemacs-1.006 / xemacs-1 / lib / xemacs-19.13 / lisp / prim / case-table.el < prev    next >
Encoding:
Text File  |  1995-03-25  |  4.2 KB  |  117 lines

  1. ;;; case-table.el --- code to extend the character set and support case tables.
  2. ;; Keywords: i18n
  3.  
  4. ;; Copyright (C) 1988, 1993 Free Software Foundation, Inc.
  5.  
  6. ;; This file is part of XEmacs.
  7.  
  8. ;; XEmacs is free software; you can redistribute it and/or modify it
  9. ;; under the terms of the GNU General Public License as published by
  10. ;; the Free Software Foundation; either version 2, or (at your option)
  11. ;; any later version.
  12.  
  13. ;; XEmacs is distributed in the hope that it will be useful, but
  14. ;; WITHOUT ANY WARRANTY; without even the implied warranty of
  15. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16. ;; General Public License for more details.
  17.  
  18. ;; You should have received a copy of the GNU General Public License
  19. ;; along with XEmacs; see the file COPYING.  If not, write to the Free
  20. ;; Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  
  22.  
  23. ;; Written by:
  24. ;; TN/ETX/TX/UMG Howard Gayle        UUCP : seismo!enea!erix!howard
  25. ;; Telefonaktiebolaget L M Ericsson  Phone: +46 8 719 55 65
  26. ;; Ericsson Telecom              Telex: 14910 ERIC S
  27. ;; S-126 25 Stockholm                FAX  : +46 8 719 64 82
  28. ;; Sweden
  29.  
  30. ;;;###autoload
  31. (defun describe-buffer-case-table ()
  32.   "Describe the case table of the current buffer."
  33.   (interactive)
  34.   (let ((vector (make-vector 256 nil))
  35.     (case-table (current-case-table))
  36.     (ch 0))
  37.     (with-output-to-temp-buffer "*Help*"
  38.       (set-buffer standard-output)
  39.       (while (< ch 256)
  40.     (cond ((/= ch (downcase ch))
  41.            (insert (text-char-description ch))
  42.            (indent-to 16)
  43.            (insert "uppercase, matches "
  44.                (text-char-description (downcase ch))
  45.                "\n"))
  46.           ((/= ch (upcase ch))
  47.            (insert (text-char-description ch))
  48.            (indent-to 16)
  49.            (insert "lowercase, matches "
  50.                (text-char-description (upcase ch))
  51.                "\n"))
  52. ;;          (t
  53. ;;           (insert (text-char-description ch))
  54. ;;           (indent-to 16)
  55. ;;           (insert "case-invariant\n"))
  56.           )
  57.     (setq ch (1+ ch))))))
  58.  
  59. (defun invert-case (count)
  60.   "Change the case of the character just after point and move over it.
  61. With arg, applies to that many chars.
  62. Negative arg inverts characters before point but does not move."
  63.   (interactive "p")
  64.   (if (< count 0)
  65.       (progn (setq count (min (1- (point)) (- count)))
  66.          (forward-char (- count))))
  67.   (while (> count 0)
  68.     (let ((ch (following-char)))
  69.       (cond ((/= (upcase ch) ch)
  70.          (insert (upcase ch))
  71.          (delete-char 1))
  72.         ((/= (downcase ch) ch)
  73.          (insert (downcase ch))
  74.          (delete-char 1))
  75.         (t
  76.          (forward-char 1))))
  77.     (setq count (1- count))))
  78.  
  79. (defun set-case-syntax-delims (l r table)
  80.   "Make characters L and R a matching pair of non-case-converting delimiters.
  81. Sets the entries for L and R in standard-case-table,
  82. standard-syntax-table, and text-mode-syntax-table to indicate
  83. left and right delimiters."
  84.   (aset (car table) l l)
  85.   (aset (car table) r r)
  86.   (modify-syntax-entry l (concat "(" (char-to-string r) "  ")
  87.                (standard-syntax-table))
  88.   (modify-syntax-entry l (concat "(" (char-to-string r) "  ")
  89.                text-mode-syntax-table)
  90.   (modify-syntax-entry r (concat ")" (char-to-string l) "  ")
  91.                (standard-syntax-table))
  92.   (modify-syntax-entry r (concat ")" (char-to-string l) "  ")
  93.                text-mode-syntax-table))
  94.  
  95. (defun set-case-syntax-pair (uc lc table)
  96.   "Make characters UC and LC a pair of inter-case-converting letters.
  97. Sets the entries for characters UC and LC in
  98. standard-case-table, standard-syntax-table, and
  99. text-mode-syntax-table to indicate an (uppercase, lowercase)
  100. pair of letters."
  101.   (aset (car table) uc lc)
  102.   (modify-syntax-entry lc "w   " (standard-syntax-table))
  103.   (modify-syntax-entry lc "w   " text-mode-syntax-table)
  104.   (modify-syntax-entry uc "w   " (standard-syntax-table))
  105.   (modify-syntax-entry uc "w   " text-mode-syntax-table))
  106.  
  107. (defun set-case-syntax (c syntax table)
  108.   "Make characters C case-invariant with syntax SYNTAX.
  109. Sets the entries for character C in standard-case-table,
  110. standard-syntax-table, and text-mode-syntax-table to indicate this.
  111. SYNTAX should be \" \", \"w\", \".\" or \"_\"."
  112.   (aset (car table) c c)
  113.   (modify-syntax-entry c syntax (standard-syntax-table))
  114.   (modify-syntax-entry c syntax text-mode-syntax-table))
  115.  
  116. (provide 'case-table)
  117.